package main

import (
	"fmt"
	"github.com/gofiber/fiber/v2"
	_ "github.com/lib/pq"
	"go-fiber-rest-api/database"
	"go-fiber-rest-api/router"
	"log"
)

// entry point to our program
func main() {
	// Connect to database
	if err := database.Connect(); err != nil {
		log.Fatal(err)
	}

	// call the New() method - used to instantiate a new Fiber App
	app := fiber.New()
	// Middleware
	//app.Use(middleware.AuthReq())

	router.SetupRoutes(app)

	// listen on port 3000
	err := app.Listen(":3000")
	if err != nil {
		fmt.Println(err)
		log.Fatal("listen on port 3000 fail")
	}
}
